import dict from '@/const/dict/dict';

export default (safe) => {
  return {
    height: 'auto',
    calcHeight: 30,
    tip: false,
    searchShow: true,
    border: true,
    index: true,
    viewBtn: true,
    selection: true,
    dialogClickModal: false,
    grid: false,
    gridBtn: false,
    dialogDrag: true,
    labelWidth: 100,
    defaultSort: {
      prop: 'updateTime',
      order: 'descending'
    },
    column: [
      {
        label: '主键',
        prop: 'id',
        type: 'input',
        display: false,
        hide: true
      },
      {
        label: '接码平台',
        prop: 'serviceApiId',
        type: 'select',
        dicUrl: '/biz/search/select/sms-api',
        dicHeaders: { crypto: true },
        dicMethod: 'post',
        dataType: 'string',
        props: {
          label: 'dictValue',
          value: 'dictKey'
        },
        search: false,
        searchLabelWidth: 100,
        display: false,
        hide: true
      },
      {
        label: '平台配置',
        prop: 'serviceConfigId',
        component: 'sms-service-select',
        params: {
          checkType: 'radio'
        },
        search: false,
        searchSpan: 6,
        searchLabelWidth: 100,
        display: false,
        hide: true
      },
      {
        label: '国家',
        prop: 'countryMappingId',
        type: 'select',
        dicUrl: '/biz/search/select/mapping-country',
        dicHeaders: { crypto: true },
        dicQuery: { serviceApiId: safe.$props.serviceApiId },
        dicMethod: 'post',
        dataType: 'string',
        props: {
          label: 'dictValue',
          value: 'dictKey'
        },
        search: true,
        searchSpan: 6,
        searchLabelWidth: 75,
        filterable: true,
        virtualize: true,
        display: false
      },
      {
        label: '最大价格',
        prop: 'maxPrice',
        type: 'input',
        display: false
      },
      {
        label: '运营商',
        prop: 'operatorArray',
        type: 'checkbox',
        gridRow: true,
        showOverflowTooltip: true,
        display: false
      },
      {
        label: '修改人',
        prop: 'updateUser',
        type: 'input',
        display: false
      },
      {
        label: '修改时间',
        prop: 'updateTime',
        type: 'datetime',
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
        startPlaceholder: '开始日期',
        endPlaceholder: '结束日期',
        display: false,
        sortable: 'custom',
        width: 180
      },
      {
        label: '设备类型',
        prop: 'deviceType',
        type: 'select',
        dicUrl: '/biz/search/dictionary/dict-biz',
        dicHeaders: { crypto: true },
        dicQuery: { code: 'device' },
        dicMethod: 'post',
        dataType: 'number',
        props: {
          label: 'dictValue',
          value: 'dictKey'
        },
        display: false
      },
      {
        label: '线程数',
        prop: 'threadCount',
        display: false
      },
      {
        label: '状态',
        prop: 'status',
        type: 'switch',
        dicData: dict.enable_disable,
        dataType: 'number',
        search: true,
        searchLabelWidth: 75,
        filterable: true,
        virtualize: true,
        display: false
      },
    ],
    group: [
      {
        label: '平台设置',
        prop: 'smsGroup',
        column: [
          {
            label: '接码平台',
            prop: 'serviceApiId',
            type: 'select',
            dicUrl: '/biz/search/select/sms-api',
            dicHeaders: { crypto: true },
            dicMethod: 'post',
            dataType: 'string',
            props: {
              label: 'dictValue',
              value: 'dictKey'
            },
            rules: [{
              required: true,
              message: '请输入SMS接码平台',
              trigger: 'blur'
            }],
            disabled: true
          },
          {
            label: '国家',
            prop: 'countryMappingId',
            type: 'select',
            dicUrl: '/biz/search/select/mapping-country',
            dicHeaders: { crypto: true },
            dicQuery: { serviceApiId: safe.$props.serviceApiId },
            dicMethod: 'post',
            dataType: 'string',
            props: {
              label: 'dictValue',
              value: 'dictKey'
            },
            cascader: ['operatorArray'],
            filterable: true,
            virtualize: true,
            rules: [{
              required: true,
              message: '请输入国家映射',
              trigger: 'blur'
            }]
          },
          {
            label: '最大价格',
            labelTip: '平台为5sim时,仅选择随机国家时有效.',
            prop: 'maxPrice',
            type: 'number',
            disabled:false,
            controls: false
          },
          {
            label: '号段排除',
            labelTip: '号码排除的前缀,请使用逗号输入。记录格式：国家代码和 3 至 6 位掩码数字（如 7918、7900111）',
            prop: 'phoneException',
            type: 'input',
            disabled:false,
          },
          {
            label: '运营商',
            prop: 'operatorArray',
            type: 'checkbox',
            dicUrl: '/biz/search/select/sms-operator',
            dicHeaders: { crypto: true },
            dicQuery: { id: `{{countryMappingId}}` },
            dicMethod: 'post',
            dataType: 'string',
            props: {
              label: 'dictValue',
              value: 'dictKey'
            },
            row: true,
            span: 24,
            rules: [],
          }
        ]
      },
      {
        label: '代理设置',
        prop: 'proxyGroup',
        column: [
          {
            label: '代理平台',
            prop: 'proxyId',
            type: 'cascader',
            multiple: true,
            dicUrl: '/biz/search/select/task-proxy-platform',
            dicHeaders: { crypto: true },
            dicMethod: 'post',
            dataType: 'string',
            props: {
              label: 'dictValue',
              value: 'dictKey'
            },
            emitPath: false,
            expandTrigger: 'click',
            value: '1830547285613178881',
            rules: [{
              required: true,
              message: '请选择代理设置',
              trigger: 'blur'
            }]
          },
          {
            label: '代理(国家)',
            labelTip: '不选择则使用随机国家',
            prop: 'proxyCountryId',
            type: 'select',
            dicUrl: '/biz/search/select/country',
            dicHeaders: { crypto: true },
            dicMethod: 'post',
            dataType: 'string',
            props: {
              label: 'dictValue',
              value: 'dictKey'
            },
            filterable: true,
            virtualize: true
          }
        ]
      },
      {
        label: '任务参数',
        prop: 'taskGroup',
        column: [
          {
            label: '设备类型',
            prop: 'deviceType',
            type: 'select',
            dicUrl: '/biz/search/dictionary/dict-biz',
            dicHeaders: { crypto: true },
            dicQuery: { code: 'device' },
            dicMethod: 'post',
            dataType: 'number',
            props: {
              label: 'dictValue',
              value: 'dictKey'
            },
            rules: [{
              required: true,
              message: '请选择设备类型',
              trigger: 'blur'
            }],
            value: 12
          },
          {
            label: '是否真机',
            labelTip: '搭配真机辅助下发',
            prop: 'isRealDevice',
            type: 'select',
            dicData: dict.yes_no,
            dataType: 'number',
            rules: [{
              required: true,
              message: '请选择是否真机',
              trigger: 'blur'
            }],
            value: 1
          },
          {
            label: '是否检测',
            labelTip: '下发时检查该号码是否已注册',
            prop: 'isCheck',
            type: 'select',
            dicData: dict.yes_no,
            dataType: 'number',
            rules: [{
              required: true,
              message: '请选择是否检测',
              trigger: 'blur'
            }],
            value: 1
          },
          {
            label: '是否改机',
            labelTip: '下发失败切换其他设备类型',
            prop: 'isNoRoutesChangeDevice',
            type: 'select',
            dicData: dict.yes_no,
            dataType: 'number',
            rules: [{
              required: true,
              message: '请选择是否改机',
              trigger: 'blur'
            }],
            value: 1
          },
          {
            label: '线程数',
            labelTip: '每次取号数量',
            prop: 'threadCount',
            type: 'number',
            step: 1,
            stepStrictly: true,
            controls: false,
            rules: [{
              required: true,
              message: '请输入线程数',
              trigger: 'blur'
            }],
            value: 1
          },
          {
            label: '重试次数',
            labelTip: '下发为`no_routes`重试次数',
            prop: 'retryCount',
            type: 'number',
            max: 3,
            step: 1,
            stepStrictly: true,
            controls: false
          },
          {
            label: '最大注册数',
            prop: 'maxRegisterCount',
            type: 'number',
            step: 1,
            stepStrictly: true,
            controls: false,
          },
          {
            label: '状态',
            prop: 'status',
            type: 'switch',
            dicData: dict.enable_disable,
            dataType: 'number',
            value: 1,
            filterable: true,
            virtualize: true
          }
        ]
      }
    ]
  };
};
